package com.example.controller;

import com.example.common.Pager;
import com.example.common.Result;
import com.example.entity.AreaMessage;
import com.example.entity.ComputerMessage;
import com.example.entity.ComputerUse;
import com.example.entity.ReaderMessage;
import com.example.service.AreaMessageService;
import com.example.service.ComputerMessageService;
import com.example.service.ReaderMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author 紫煦桉
 */
@RequestMapping("/computerUse")
@Controller
public class ComputerUseController extends SuperController<ComputerUse> {

    private ComputerMessageService computerMessageService;
    private ReaderMessageService readerMessageService;
    private AreaMessageService areaMessageService;
    @Autowired
    private void setService(ComputerMessageService computerMessageService, ReaderMessageService readerMessageService, AreaMessageService areaMessageService) {
        this.computerMessageService = computerMessageService;
        this.readerMessageService = readerMessageService;
        this.areaMessageService = areaMessageService;
    }

    @RequestMapping("/computerMessageList")
    @ResponseBody
    public List<ComputerMessage> allComputerMessage() {
        return computerMessageService.findAll();
    }

    @RequestMapping("/readerMessageList")
    @ResponseBody
    public List<ReaderMessage> allReaderMessage() {
        return readerMessageService.findAll();
    }

    @RequestMapping("/areaMessageList")
    @ResponseBody
    public List<AreaMessage> allAreaMessage() {
        return areaMessageService.findAll();
    }

    @Override
    @RequestMapping("/list")
    @ResponseBody
    public Pager<ComputerUse> list(ComputerUse param, @RequestParam(defaultValue = "1", value = "page") String page,
                                   @RequestParam(defaultValue = "10", value = "rows") String size) {
        return super.list(param, page, size);
    }

    @Override
    @RequestMapping("/add")
    @ResponseBody
    public Result add(ComputerUse param) {
        return super.add(param);
    }

    @Override
    @RequestMapping("/edit")
    @ResponseBody
    public Result edit(ComputerUse param) {
        return super.edit(param);
    }

    @Override
    @RequestMapping("/delete")
    @ResponseBody
    public Result delete(ComputerUse param) {
        return super.delete(param);
    }
}
